package org.client.iot.http;

import org.client.iot.domain.CaptchaImageDto;
import org.client.iot.domain.DataInfo;
import org.client.iot.domain.DataListDto;
import org.client.iot.domain.DataQuantityDto;
import org.client.iot.domain.DebugOptionsDto;
import org.client.iot.domain.DevChargeInfoVo;
import org.client.iot.domain.DevConfigureDto;
import org.client.iot.domain.DeviceDto;
import org.client.iot.domain.DeviceInfoDto;
import org.client.iot.domain.DownHoleDto;
import org.client.iot.domain.HoleDto;
import org.client.iot.domain.LoginDto;
import org.client.iot.domain.ProjectDto;
import org.client.iot.domain.SensorDetectionDto;
import org.client.iot.domain.TrialDto;
import org.client.iot.domain.UserDto;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;

/**
 * @Date 2025/8/18  10:01
 * @Description ApiService接口 统一管理应用所有的接口
 */

public interface ApiService {
    String devPrefix = "/qt/";
    //获取验证码图片
    @GET("/prod-api/captchaImage")
    Observable<CaptchaImageDto> getCaptchaImage();

    //登录
    @POST("/prod-api/login")
    @Headers("Content-Type: application/json")
    Observable<LoginDto> login(@Body RequestBody jsonBody);

    //获取用户信息
    @GET("/prod-api/getInfo")
    Observable<UserDto> getInfo(@Header("Authorization") String token);

    //获取项目列表
    @GET("/prod-api/iot/project/list?")
    Observable<BaseRes<ProjectDto>> getProjectList(@Header("Authorization") String token, @Query("pageNum") int pageNum, @Query("pageSize") int pageSize);

    //新增项目
    @POST("/prod-api/iot/project")
    @Headers("Content-Type: application/json")
    Observable<UpdateReqDto> addProject(@Header("Authorization") String token, @Body RequestBody jsonBody);

    //获取项目设备列表
    @GET("/prod-api/iot/device/shortList?")
    Observable<BaseRes<DeviceDto>> getShortList(@Header("Authorization") String token, @Query("pageNum") int pageNum, @Query("pageSize") int pageSize, @Query("productId") String productId, @Query("projectId") String projectId, @Query("deviceName") String deviceName);

    //设备新增
    @POST("/prod-api/iot/device")
    @Headers("Content-Type: application/json")
    Observable<UpdateReqDto> addDevice(@Header("Authorization") String token, @Body RequestBody jsonBody);


    //设备复位
    @POST(devPrefix + "/device/reset")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> devReset(@Body RequestBody jsonBody);

    //生产测试
    @POST(devPrefix + "/device/trial")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<TrialDto>> devTrial(@Body RequestBody jsonBody);

    //传感器检测接口
    @POST(devPrefix + "/device/sensordetection")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<SensorDetectionDto>> devSensorDetection(@Body RequestBody jsonBody);

    //获取设备信息
    @GET(devPrefix + "/device/info")
    Observable<BaseDevReq<DeviceInfoDto>> getDevInfo();

    //手动入网接口
    @POST(devPrefix + "/device/manualnetworkaccess")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> manualNetworkAccess(@Body RequestBody jsonBody);


    //查询设备数据数量接口
    @POST(devPrefix + "/device/dataquantity")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<DataQuantityDto>> dataQuantity(@Body RequestBody jsonBody);

    //清除数据接口
    @POST(devPrefix + "/device/dataclear")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> dataClear(@Body RequestBody jsonBody);

    //离线保存数据接口
    @POST(devPrefix + "/device/datasave")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> dataSave(@Body RequestBody jsonBody);

    //数据上传接口
    @POST(devPrefix + "/device/dataupload")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> dataUpload(@Body RequestBody jsonBody);

    //获取设备配置接口
    @GET(devPrefix + "/device/setting")
    Observable<BaseDevReq<DevConfigureDto>> getDevSetting();

    //加载设备配置接口
    @POST(devPrefix + "/device/settingload")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> settingLoad(@Body RequestBody jsonBody);

    //上传设备配置接口
    @POST(devPrefix + "/device/settingupload")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> settingUpload(@Body RequestBody jsonBody);

    //查询设备全部数据数量
    @GET(devPrefix + "/device/offlinedataquantity")
    Observable<BaseDevReq<Object>> getOfflineDataQuantity();


    //获取调试参数接口
    @GET(devPrefix + "/device/debugoptions")
    Observable<BaseDevReq<DebugOptionsDto>> getDebugOptions();

    //测量接口
    @POST(devPrefix + "/device/hole")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<HoleDto>> hole(@Body RequestBody jsonBody);

    //获取测量参数详情接口
    @GET(devPrefix + "/device/datalist")
    Observable<BaseDevReq<List<DataListDto>>> getDataList(@Query("start_time") String start_time, @Query("end_time") String end_time, @Query("type") int type);

    //获取测量参数详情接口
    @GET(devPrefix + "/device/datainfo")
    Observable<BaseDevReq<List<DataInfo>>> getDataInfo(@Query("id") int id);

    //孔探接口
    @POST(devPrefix + "/device/downhole")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<DownHoleDto>> downHole(@Body RequestBody jsonBody);

    //松开刹车接口
    @POST(devPrefix + "/device/brake")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> brake(@Body RequestBody jsonBody);

    //修改工作模式接口
    @POST(devPrefix + "/device/changeworkingmode")
    @Headers("Content-Type: application/json")
    Observable<BaseDevReq<Object>> changeWorkingMode(@Body RequestBody jsonBody);
}

